﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using GameFramework.Geometry;

namespace MyRaceGame.GameLogic
{
    public class EllipticRaceTrack : RaceTrack
    {
        /// <summary>
        /// Creates a new instace of EllipticRaceTrack.
        /// </summary>
        /// <param name="ellipse">Ellipse representing race track.</param>
        /// <param name="nDivisions">Number of divisions on the track.</param>
        /// <param name="trackWidth">Width of the track.</param>
        /// <param name="graphicsDevice">Graphics device.</param>
        /// <param name="raceTileAsset">Race track tile asset to draw tile based track.</param>
        public EllipticRaceTrack(Ellipse ellipse, int nDivisions,
            float trackWidth, GraphicsDevice graphicsDevice, Texture2D raceTileAsset)
            : base(ellipse.EllipseVertices, nDivisions, trackWidth, graphicsDevice, raceTileAsset)
        {
            this.raceTrackEllipse = ellipse;
        }

        /// <summary>
        /// Extends race track by given amount.
        /// </summary>
        /// <param name="extentionAmount">Amount of extension.</param>
        /// <param name="copyAsset">Determines if asset should be copied to extension.</param>
        /// <returns></returns>
        public EllipticRaceTrack GetExtendedRaceTrack(float extentionAmount, bool copyAsset = false)
        {
            return new EllipticRaceTrack(raceTrackEllipse.GetExtendedEllipse(extentionAmount), nDivisions,
                trackWidth, graphicsDevice, copyAsset ? texture : null);
        }

        /// <summary>
        /// Ellipse representing race track.
        /// </summary>
        public Ellipse RaceTrackEllipse
        {
            get { return raceTrackEllipse; }
            set { raceTrackEllipse = value; }
        }

        protected Ellipse raceTrackEllipse;
    }
}
